import { Component } from 'react';
import { Col, Row } from 'antd';
import styles from './index.less';
import { CircleIcon } from '@/components/SelfIcon';

export interface TitleProps {
  label?: string; // 显示的文字
  rightCbk?: () => any; // 右边显示数据
  code?: string; // id
}

export default class Title extends Component<TitleProps, any> {
  render() {
    const { label, rightCbk, code } = this.props;
    return (
      <Row>
        <Col span={rightCbk ? 18 : 24}>
          <div id={code} className={styles.title}>
            <CircleIcon className={styles['title-circle-icon']} />
            <span className={styles.info}>{label == 'null' ? '未命名' : label}</span>
          </div>
        </Col>
        {rightCbk ? (
          <Col span={6}>
            <div className={styles.title}>{rightCbk()}</div>
          </Col>
        ) : null}
      </Row>
    );
  }
}
